package com.ruoyi.project.lesson.channel.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.lesson.channel.domain.LessonChannel;
import com.ruoyi.project.lesson.channel.mapper.LessonChannelMapper;
import com.ruoyi.project.lesson.channel.service.ILessonChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课程渠道Service业务层处理
 *
 * @author shixiangwen
 * @date 2021-04-21
 */
@Service
@DataSource(DataSourceType.KKFORMULA)
public class LessonChannelServiceImpl implements ILessonChannelService {
    @Autowired
    private LessonChannelMapper lessonChannelMapper;

    /**
     * 查询课程渠道
     *
     * @param id 课程渠道ID
     * @return 课程渠道
     */
    @Override
    public LessonChannel selectLessonChannelById(Long id) {
        return lessonChannelMapper.selectLessonChannelById(id);
    }

    /**
     * 查询课程渠道列表
     *
     * @param lessonChannel 课程渠道
     * @return 课程渠道
     */
    @Override
    public List<LessonChannel> selectLessonChannelList(LessonChannel lessonChannel) {
        return lessonChannelMapper.selectLessonChannelList(lessonChannel);
    }

    /**
     * 新增课程渠道
     *
     * @param lessonChannel 课程渠道
     * @return 结果
     */
    @Override
    public int insertLessonChannel(LessonChannel lessonChannel) {
        lessonChannel.setCreatedTime(DateUtils.getNowDate());
        return lessonChannelMapper.insertLessonChannel(lessonChannel);
    }

    /**
     * 修改课程渠道
     *
     * @param lessonChannel 课程渠道
     * @return 结果
     */
    @Override
    public int updateLessonChannel(LessonChannel lessonChannel) {
        return lessonChannelMapper.updateLessonChannel(lessonChannel);
    }

    /**
     * 删除课程渠道对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLessonChannelByIds(String ids) {
        return lessonChannelMapper.deleteLessonChannelByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除课程渠道信息
     *
     * @param id 课程渠道ID
     * @return 结果
     */
    @Override
    public int deleteLessonChannelById(Long id) {
        return lessonChannelMapper.deleteLessonChannelById(id);
    }
}
